Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@entur/tokens
Advanced tools
This package contains all design tokens and design variables used throughout the design system. We are currently in a process to migrate over to a new design variable system based on [Figma Variables](https://help.figma.com/hc/en-us/articles/1533965713538
This package contains all design tokens and design variables used throughout the design system. We are currently in a process to migrate over to a new design variable system based on Figma Variables.
Since not all values are available as a variable yet and to avoid breaking changes, all previous design tokens will be kept around for a while. These are built from the src/legacy-tokens.ts
file.
💡 Looking for the documentation?
npm install @entur/tokens
# or if you are using Yarn:
yarn add @entur/tokens
Please refer to the documentation for in-depth usage information.
This package has several main exports:
To use the CSS file, import it into your bundle like so:
import '@entur/tokens/dist/styles.css';
You'll then have access to all design tokens as CSS variables. You can then use them like so:
.custom-box {
background-color: var(--colors-greys-grey10);
color: var(--colors-brand-coral);
font-size: var(--font-sizes-medium);
margin: var(--space-medium) var(--space-large);
}
Please refer to the design system documentation for which ones are available.
To use the LESS or SCSS files, import it into your LESS or SCSS file. The method is the same:
@import '@entur/tokens/dist/styles.less';
@import '@entur/tokens/dist/styles.scss';
You'll then be able to use the variables in your code as usual.
// LESS
.custom-box {
background-color: @colors-greys-grey10;
color: @colors-brand-coral;
font-size: @font-sizes-medium;
margin: @space-medium @space-large;
}
// SCSS
.custom-box {
background-color: $colors-greys-grey10;
color: $colors-brand-coral;
font-size: $font-sizes-medium;
margin: $space-medium $space-large;
}
To use the design tokens in JavaScript, import the ones you need like so:
import { StyleSheet } from 'react-native';
import { colors, breakpoints, fontSizes } from '@entur/tokens';
StyleSheet.create({
example: {
fontSize: fontSizes.medium,
color: colors.brand.coral,
},
});
These values are mainly provided in pixels. If you need the values in rem instead, add a .rem
after the token name, e.g. space.rem.large
for rem value and space.large
for pixel value.
There are three steps needed to update the set of available designs variables in this repo:
src
folderThe JSON is exported from Figma using the variabels2css-plugin, download the plugin if you haven't already. Go to the Figma file containing the variables you want to export, eg. Semantic Colors. In you menu bar, select 'Plugins' and choose 'variables2css' – this opens a modal. Under 'choose your collection' choose the variable set you want to export. Under 'type' choose 'JSON', and under 'color' and 'unit' choose 'hex' and 'rem'. Then click 'Generate' and copy the result.
Back in this repo, find the JSON-variables file you want to update, eg. semantic.json
, delete its content and paste the generated result you copied in step 1. Then save the file.
When the JSON-file content is updated, run the script yarn build
inside this package or yarn build:packages
from root. This will generate new files with updated values in both this package and in all other packages where the component color value has been updated. Once the build is finished, commit all changes and push the commit.
FAQs
This package contains all design tokens and design variables used throughout the design system. We are currently in a process to migrate over to a new design variable system based on [Figma Variables](https://help.figma.com/hc/en-us/articles/1533965713538
We found that @entur/tokens demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 13 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.